<template>
<div>
    <div v-if="$store.getters.Navflag=='aaa'">

    </div>
<!-- 公共底部导航组件 -->
  <div v-if="$store.getters.Navflag == 'bbb'">
      <!-- vant-ui引入的组件 -->
      <van-tabbar v-model="currIndex">
          <van-tabbar-item v-for="(item,index) in navList" :key="index" :icon="currIndex == index?item.active:item.normal" @click="turn(item.name)">
              <!-- 公共底部导航 -->
          </van-tabbar-item>
      </van-tabbar>
  </div>
     <div  v-if="$store.getters.Navflag == 'ccc'" class="buyfoot">
      <van-goods-action>
        <van-goods-action-icon icon="chat-o" text="客服" dot />
        <van-goods-action-icon icon="cart-o" text="购物车" badge="5" />
        <van-goods-action-icon icon="shop-o" text="店铺" badge="12" />
        <van-goods-action-button @click="addcart" type="warning" text="加入购物车" />
        <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action>
  </div>
</div>
</template>

<script>
import {Toast} from 'vant'
export default {
    name:"tabbar",
    methods: {
        addcart(){
            this.$store.dispatch('cartStore/addCartList')
            // console.log(this.$store.state.cartStore.cartinfo)
        },
        turn(name){
            // console.log(name)
            // console.log(this.$router.history.current.name)
            if(name == this.$router.history.current.name){
                Toast({
                      message: '别按了,别按了,受不了了',
                      icon: 'fire',
                })
                return
            }else{
            this.$router.push({name:name})
            }
        }
    },
     data() {
        return {
            currIndex:0,
            navList: [
                {
                name: "home",
                title: "首页",
                normal:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/81741/30/12345/4140/5d9c4b13E726f0a1e/82c582e7c375e4b3.png", //普通图标
                active:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/67550/26/12426/5094/5d9c4b13Eea435a3f/81328b0609c60a3c.png" //激活图标
                },
                {
                name: "category",
                title: "分类",
                normal:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/56507/6/12787/3168/5d9c4b12Ef363dd8d/4af32f42575509d8.png",
                active:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/48787/24/12910/3390/5d9c4b12Ee63270e4/4481f5b3dbad979d.png"
                },
                {
                name: "suprise",
                title: "惊喜",
                normal:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/70651/38/12417/3194/5d9d3eafE12cde68b/2467c20113c50451.png",
                active:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/70651/38/12417/3194/5d9d3eafE12cde68b/2467c20113c50451.png"
                },
                {
                name: "cart",
                title: "购物车",
                normal:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/64954/4/12406/3529/5d9c4b12Ee7a82735/f2fe0a88bf344736.png",
                active:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/45205/32/12889/3890/5d9c4b12E7bc2c425/dd60fafbde8542ca.png"
                },
                {
                name: "my",
                title: "我的",
                normal:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/56206/13/12652/2957/5d9c4b13E503bcd76/1c8543653685e80e.png",
                active:
                    "https://img11.360buyimg.com/jdphoto/s130x100_jfs/t1/47480/36/12929/3209/5d9c4b13E97caa63a/4dc0ec8a7e47c2b7.png"
                }
            ]
        }
    },
}
</script>

<style>
    .van-tabbar-item img{
        width: 120px;
        height: 120px;
    }
    .buyfoot{
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 999999;
}
</style>